// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include "CommonUserWidget.h"

#include "LyraWeaponUserInterface.generated.h"

class ULyraWeaponInstance;
class UObject;
struct FGeometry;

UCLASS()
class ULyraWeaponUserInterface : public UCommonUserWidget
{
	GENERATED_BODY()

public:
	ULyraWeaponUserInterface(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());

	/**
	 * 本地构建
	 */
	virtual void NativeConstruct() override;
	/**
	 * 本地销毁
	 */
	virtual void NativeDestruct() override;
	/**
	 * 本地Tick
	 * @param MyGeometry 几何信息
	 * @param InDeltaTime 增量时间
	 */
	virtual void NativeTick(const FGeometry& MyGeometry, float InDeltaTime) override;

	/**
	 * 当武器改变时调用（蓝图可实现事件）
	 * @param OldWeapon 旧武器
	 * @param NewWeapon 新武器
	 */
	UFUNCTION(BlueprintImplementableEvent)
	void OnWeaponChanged(ULyraWeaponInstance* OldWeapon, ULyraWeaponInstance* NewWeapon);

private:
	/**
	 * 从武器重新构建控件
	 */
	void RebuildWidgetFromWeapon();

private:
	UPROPERTY(Transient)
	TObjectPtr<ULyraWeaponInstance> CurrentInstance; //当前武器实例
};